// 监听路由改变
watch(
  () => route,
  async (newRoute) => {
    const { params: { id }, query } = newRoute;
    if (!id) router.replace("/chat");
    if (id.startsWith("local_")) {
      chatId.value = "";
      localPost.value = true;

      if (!(eventStore.chatTextAreaValue || inputTextAreaValue.value)) {
        router.replace({ path: "/chat" });
        return;
      }

      const query = eventStore.chatTextAreaValue || inputTextAreaValue.value;
      currentAskParams.value = {
        chat_id: chatId.value,
        query: query,
        refs: "",
        research: 1,
        deep: 0,
        thread_id: '',
        research_plan: '',
        report_type: "academic"
      };
      // 插入新的记录
      let chatDetailItem = chatItem({
        ask: eventStore.chatTextAreaValue || inputTextAreaValue.value,
      });
      chatDetailList.value = [...chatDetailList.value, chatDetailItem];
      scrollToBottom();
      await chatSendTalk();
    } else {
      chatId = id;
      localPost.value = false;
      // 设置chat 对话菜单
      routerStore.getChatMenu();
      if (controller) {
        generateLoading.value = false;
        controller.abort("cancel");
        currentAskParams.value = {};
      }
      closeReport()
      getChatDetail({ id: id });
    }
  },
  { immediate: true, deep: true }
);